package com.dcivision.framework.bean;

/**
 * @version $Revision: 1.1 $ $Date: 2004/11/03 06:34:35 $
 * @author  Ryan Kwan
 */
public class BeanSorterElement implements Comparable {
    
    private Object key;
    private Object bean;
    
    public BeanSorterElement(Object key, Object bean) {
        this.key = null;
        this.bean = null;
        this.key = key;
        this.bean = bean;
    }
    
    public Object getKey() {
        return key;
    }
    
    public void setKey(Object key) {
        this.key = key;
    }
    
    public Object getBean() {
        return bean;
    }
    
    public void setBean(Object bean) {
        this.bean = bean;
    }
    
    public int compareTo(Object o) {
        if(!(o instanceof BeanSorterElement))
            throw new ClassCastException();
        Object okey = ((BeanSorterElement)o).key;
        if(key == null)
            return okey != null ? -1 : 0;
            if(okey == null)
                return 1;
            else
                return ((Comparable)key).compareTo(okey);
    }
}